﻿'use strict';
angular.module('app').controller('AppCtrl', function($rootScope, $scope, $localStorage, $state, $timeout, $parse){
    var lods = [
        {"level" : 0, "resolution" : 9783.939, "scale" : 36978595.474},
        {"level" : 1, "resolution" : 4891.969, "scale" : 18489297.737},
        {"level" : 2, "resolution" : 2445.984, "scale" : 9244648.868},
        {"level" : 3, "resolution" : 1222.992, "scale" : 4622324.434},
        {"level" : 4, "resolution" : 611.496, "scale" : 2311162.217},
        {"level" : 5, "resolution" : 305.748, "scale" : 1155581.108},
        {"level" : 6, "resolution" : 152.874, "scale" : 577790.55},
        {"level" : 7, "resolution" : 76.437, "scale" : 288895.277},
        {"level" : 8, "resolution" : 38.21, "scale" : 144447.638},
        {"level" : 9, "resolution" : 19.109, "scale" : 72223.81},
        {"level" : 10, "resolution" : 9.554, "scale" : 36111.909},
        {"level" : 11, "resolution" : 4.777, "scale" : 18055.95},
        {"level" : 12, "resolution" : 2.388, "scale" : 9027.97},
        {"level" : 13, "resolution" : 1.194, "scale" : 4513.988},
        {"level" : 14, "resolution" : 0.597, "scale" : 2256.99}
    ];

    $rootScope.server = CONFIG.basePathUrl;
    $rootScope.arcgisApi = 'http://map3.wayto.com.cn:8092';
    $rootScope.arcgisLogiServer = 'http://map3.wayto.com.cn:6080/arcgis/rest/services';
    $rootScope.api = {
        account : {
            token : $rootScope.server + '/token',
        },
        unit : $rootScope.server + '/v2/unit',
        user : $rootScope.server + '/v2/user',
        device : $rootScope.server + '/v2/device',
        record : $rootScope.server + '/v2/Record',
        inspection : $rootScope.server + '/v2/inspection',
    };
    $rootScope.arcgisConfig = {
        baseMap : $rootScope.arcgisLogiServer + "/glcad/MapServer",
        arcgisServer : $rootScope.arcgisLogiServer + "/wt_device_pipe/",
        geoBasemap : "streets",
        layerInfos : "隐患点:0;设备点:1",
        layerInfosObj : [{"隐患点" : 0}, {"设备点" : 1}],
        lods : lods,
        //geoCenter:"175307.451,135762.144",
        unit : $rootScope.server + '/v2/unit',
        user : $rootScope.server + '/v2/user',
        device : $rootScope.server + '/v2/device',
        log : $rootScope.server + '/v2/log',
        record : $rootScope.server + '/v2/record',
        inspection : $rootScope.server + '/v2/inspection'
    };

    //日期公共配置
    $rootScope.dateOptions = {
        formatDayTitle : 'yyyy MMMM',//日期标题格式
        showWeeks:false,
    };
    $rootScope.format = "yyyy-MM-dd";
    $rootScope.openDate = function($event, key, scope){
        $event.preventDefault();
        $event.stopPropagation();
        if(key){
            $parse(key).assign($rootScope, true);
        }
    };
    $rootScope.roleid=$localStorage.roleid;//角色单位
    // 默认中心点
    $rootScope.centerOptions = {
        isShowPoint:true,
        "symbolUrl":  "/assets/img/Icons/聚焦框64.png",
        symbolStyle :{
            width:34,
            height:34,
            angle:0,
            xOffset : 0,
            yOffset : 17
        }
    };
});